package com.lanou.myim.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.lanou.myim.R;


/**
 * Created by dllo on 16/3/23.
 */
public class MyGrideviewAdapter extends BaseAdapter{
    private Context context;
    private int[] imageIds;


    public MyGrideviewAdapter(Context context,int[] imageIds){
        this.context = context;
        this.imageIds = imageIds;
    }

    @Override
    public int getCount() {
        return imageIds.length;
    }

    @Override
    public Object getItem(int position) {
        return imageIds[position];
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView ;
        if (convertView == null){
            imageView = new ImageView(context);

        }else {
            imageView = (ImageView)convertView;
        }
        imageView.setImageResource(imageIds[position]);
        return imageView;
    }
}
